package test01.demo04.service;

import test01.demo04.daoImpl.PersonDaoImpl;
import test01.demo04.pojo.Person;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class PersonService {

    PersonDaoImpl pdi = new PersonDaoImpl();

    /**
     * 添加单条数据
     * @param person
     * @return
     */
    public boolean insert(Person person){
        List<Person> people = new ArrayList<>();
        people.add(person);
        return insert(people);
    }

    public boolean insert(Person... person){
        List<Person> people = Arrays.asList(person);
        return insert(people);
    }

    /**
     * 添加集合形式的多条数据
     * @param person
     * @return
     */
    public boolean insert(List<Person> person){
        return pdi.insert(person);
    }

    public boolean delete(String[] ids){
        return pdi.delete(ids);
    }

    public int update(Person person){
        return pdi.update(person);
    }

    public List<Map<String, Object>> getAll(){
        return pdi.getAll();
    }

    public List<Map<String, Object>> getPersonForPage(int pagesize, int pageOrder){
        return pdi.getPersonForPage(pagesize,pageOrder);
    }

    public Person getPersonById(String id){
        return pdi.getPersonById(id);
    }
}
